//
//  SDSubdivideModel.m
//  SuperDoctor
//
//  Created by 李忠 on 7/9/16.
//  Copyright © 2016 SD. All rights reserved.
//

#import "SDSubdivideModel.h"
#import "NetWorkDefine.h"
#import "SDNetWorkTool.h"
#import "MJExtension.h"
#import "NSString+SDPinyin.h"


@implementation SDSubdivideModel

+ (void)subdividesWithSccucess:(SccucessBlock)sccucessBlock withError:(ErrorBlock)errorBLock{
    NSString *urlString = kSearchCI3Url;
    
    NSDictionary *paramDic = @{
                               @"page_size":@15,
                               @"page":@1,
                               @"ci1_id":@1,
                               @"keyword":@""
                               };
    [[SDNetWorkTool shareManager] POST_RequestWithUrlString:urlString parmas:paramDic successBloock:^(id responseObject) {
        
        NSArray *tempArr = [SDSubdivideModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"]];
        NSMutableArray *tempArrM = [NSMutableArray array];
        [tempArr enumerateObjectsUsingBlock:^(SDSubdivideModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            obj.namePinYin = [obj.ci3_name sd_transformToPinyin];
            obj.nameFirstLetter = [obj.ci3_name sd_transformToPinyinFirstLetter];
            [tempArrM addObject:obj];
        }];
        if (sccucessBlock) {
//            sccucessBlock(tempArr);
            sccucessBlock(tempArrM.copy);
        }
        
        
    } failureBlock:^(NSError *error) {
        if (errorBLock) {
            errorBLock(error);
        }
    }];
}

+ (NSArray *)getSydorme{
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"homePatient.plist" ofType:nil];
    NSArray *tempArr = [NSArray arrayWithContentsOfFile:filePath];
    return [SDSubdivideModel mj_objectArrayWithKeyValuesArray:tempArr];
}
+ (NSArray *)getSureWay{
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"curePatient.plist" ofType:nil];
    NSArray *tempArr = [NSArray arrayWithContentsOfFile:filePath];
    return [SDSubdivideModel mj_objectArrayWithKeyValuesArray:tempArr];
}
@end
